package com.manli.api.service;

import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.SQLReady;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.List;
import com.manli.api.pojo.Result;
import com.manli.api.util.ResultUtil;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.manli.api.pojo.QueryParams;
import com.manli.api.dao.ManliSpaceLikeCountLogDao;
import com.manli.api.dto.ManliSpaceLikeCountLog;


@Service("manliSpaceLikeCountLogService")
public class ManliSpaceLikeCountLogService {
    @Autowired
    ManliSpaceLikeCountLogDao manliSpaceLikeCountLogDao;
    @Autowired
    SQLManager sqlManager;

    
    public Result queryPage(QueryParams params) {
        /**
        * sql中表名需要修改
        */
        StringBuffer sql = new StringBuffer("select * from manliSpaceLikeCountLog where 1=1 ");

        SQLReady sqlReady = new SQLReady(sql.toString());

        PageQuery<ManliSpaceLikeCountLog> pageQuery = new PageQuery<ManliSpaceLikeCountLog>(params.getPage(),params.getLimit());
        PageQuery<ManliSpaceLikeCountLog> query =sqlManager.execute(sqlReady,ManliSpaceLikeCountLog.class,pageQuery);
        return ResultUtil.success(query.getList(),query.getTotalRow());
    }

    
    public Result queryAll() {
        List<ManliSpaceLikeCountLog> list = manliSpaceLikeCountLogDao.all();
        return ResultUtil.success(list);
    }

    
    public Result getById(Integer likeCountId) {
        ManliSpaceLikeCountLog manliSpaceLikeCountLog = manliSpaceLikeCountLogDao.single(likeCountId);
        return ResultUtil.success(manliSpaceLikeCountLog);
    }

    @Transactional
    public Result save(ManliSpaceLikeCountLog manliSpaceLikeCountLog) {
        manliSpaceLikeCountLogDao.insert(manliSpaceLikeCountLog);
        return ResultUtil.success();
    }

    @Transactional
    public Result updateById(ManliSpaceLikeCountLog manliSpaceLikeCountLog) {
        manliSpaceLikeCountLogDao.updateTemplateById(manliSpaceLikeCountLog);
        return ResultUtil.success();
    }

    @Transactional
	public Result updateTemplateById(ManliSpaceLikeCountLog manliSpaceLikeCountLog) {
        manliSpaceLikeCountLogDao.updateTemplateById(manliSpaceLikeCountLog);
        return ResultUtil.success();
    }

    @Transactional
    public Result removeByIds(List<Integer> ids) {
        for (Integer id:ids) {
            manliSpaceLikeCountLogDao.deleteById(id);
        }
        return ResultUtil.success();
    }



}
